package com.yan;

import com.yan.config.KafkaConfig;
import com.yan.config.MysqlConfig;
import com.yan.config.RedisConfig;
import com.yan.configSource.ConfigSource;
import com.yan.configSource.ZookeeperConfigSource;

/**
 * @author yanheng
 * @data 2020/1/2 18:33
 */
public class Application {
    private static  ConfigSource configSource = new ZookeeperConfigSource();
    public static final RedisConfig redisConfig = new RedisConfig(configSource);
    public static final KafkaConfig kafkaConfig = new KafkaConfig(configSource);

    public static final MysqlConfig mysqlConfig = new MysqlConfig(configSource);

    public static void main(String[] args) {
        ScheduledUpdater redisConfigUpdater = new ScheduledUpdater(redisConfig, 300, 300);
        redisConfigUpdater.run();

        ScheduledUpdater kafakConfigUpdate = new ScheduledUpdater(kafkaConfig, 60, 60);
        kafakConfigUpdate.run();

        SimpleHttpServer simpleHttpServer = new SimpleHttpServer("localhost", 2389);
        simpleHttpServer.addViewers("/config", redisConfig);
        simpleHttpServer.addViewers("/config", mysqlConfig);
        simpleHttpServer.run();
    }
}
